package homework;

public class SuperA {
    private Object[] objects = new Object[]{
            new Student("刘一",20,"男"),
            new Student("朱二",21,"男"),
            new Student("赵三",21,"男"),
            new Student("王四",19,"女")
    };



    public void add(Object value) {
        Object [] newObject = new Object[objects.length + 1];

        for (int i = 0 ; i < objects.length; i++){
            newObject[i] = objects[i];
        }
        newObject[newObject.length - 1] = value;

        objects = newObject;
    }

    public int size() {
        return objects.length;
    }

    public Object get(int index) {
        return objects[index];
    }

    public void remove(int index) {
        Object[] newArys = new Object[objects.length -1];
        for (int i =0;i < newArys.length;i++){
            if (i >= index){
                newArys[i] = objects[i + 1];
            }else {
                newArys[i] = objects[i];
            }
        }
        objects = newArys;
    }
}
